<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
import config from "@/api/config.js";
import * as dd from 'dingtalk-jsapi'
import {mapState} from "vuex"; // 此方式为整体加载，也可按需进行加载
import {
  getDDConfig
} from '@/utils/dd' // dd.config授权
export default {
  name: "App",
  computed: {
    ...mapState(['user']),
  },
  mounted() {
    // 检测版本更新
    this.checkVersion().then(()=>{
      // 是否有权限，没有则调用个人信息接口
      // 注释
      if (dd.env.platform !== 'notInDingTalk') {
        // console.log('this.user', this.user)
        // if(this.user&&this.user.id){
        //   this.$store.dispatch('getMemberInfo', {id:this.user.id})
        // }
      }
    })
    // 是否有权限，没有则调用个人信息接口
    // 注释
    // if (dd.env.platform !== 'notInDingTalk') {
    //   this.$store.dispatch('getMemberInfo')
    //   // dd.config授权
    //   getDDConfig()
    // }
    if(this.user&&this.user.id){
      this.$store.dispatch('getMemberInfo', {id:this.user.id})
    }else{
      this.$store.commit('clearMember')
    }
  },
  methods: {
    checkVersion() {
      return new Promise((resove)=>{
        const lastVersion = config.releaseVersion || '';
        const version = localStorage.getItem('version');
        if (!version) {
          localStorage.setItem('version', lastVersion || '')
        } else {
          if (version != lastVersion) {
            localStorage.removeItem('version')
            this.$store.commit('clearMember')
            window.location.reload();
          }
        }
        resove()
      })
    },
  }
};
</script>

<style lang="less">
@import '~@/assets/css/common.less';
@import '~@/common/common.less';

html,
body {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0px;
    margin: 0px;
}
#app {
    font-family: "Avenir", Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    //color: #2c3e50;
    color: #03111f;
    width: 100%;
    height: 100%;
}
</style>

<!--<style lang="scss">-->
<!--@import "~@/assets/scss/common/common.scss";-->
<!--@import "~@/assets/scss/xr-theme.scss";-->
<!--</style>-->
